package com.e3.sysmg.config.client;

import java.util.List;

import com.e3.sysmg.config.model.ParameterModel;
import com.e3.sysmg.config.model.ParameterQC;
import com.e3.sysmg.config.model.ParameterTreeModel;
import com.e3.template.tgf.MyTGFExUI;
import com.e3.template.tgf.TGFEditorDialog;
import com.e3.template.tgf.TGFFormPanel;
import com.e3.template.tgf.TGFGridPanel;
import com.e3.template.tgf.TGFQueryDialog;
import com.e3.template.tgf.TGFTreePanel;
import com.google.gwt.user.client.rpc.AsyncCallback;

public class ParameterUI extends MyTGFExUI<ParameterModel, ParameterTreeModel> {
	
	private ParameterRPCServiceAsync service = ParameterRPCService.Util.getInstance();

	@Override
	protected TGFTreePanel<ParameterTreeModel> createTreePanel() {
		return new ParameterTreePanel();
	}

	@Override
	protected void executeQueryService(ParameterTreeModel model,AsyncCallback<List<ParameterModel>> callback) {
		if(model == null){
			return;
		}
		ParameterQC qc = new ParameterQC();
		qc.setType(model.getCode());
		service.getParameterByCondition(qc, callback);
	}

	@Override
	protected TGFFormPanel<ParameterModel> createFormPanel() {
		return new ParameterFormPanel();
	}

	@Override
	protected TGFGridPanel<ParameterModel> createGridPanel() {
		return new ParameterGridPanel();
	}

	@Override
	protected TGFQueryDialog<ParameterModel> createQueryDialog() {
		return new ParameterQueryDialog();
	}

	@Override
	protected TGFEditorDialog<ParameterModel> createEditorDialog() {
		return new ParameterEditorDialog();
	}

	@Override
	protected void executeDeleteService(List<ParameterModel> models,AsyncCallback<Void> callback) {
		service.deleteParameters(models, callback);
	}

	@Override
	protected String getCurrentLocalName() {
		return ParameterMessages.INSTANCE.local_name();
	}

	@Override
	protected ParameterModel createModelInstance() {
		return ParameterHelper.INSTANCE.createModelInstance();
	}

}
